//
//  ViewController.m
//  FightingGame
//
//  Created by iD Student on 6/25/13.
//  Copyright (c) 2013 iD Student. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController
@synthesize selectedRow = _selectedRow;

- (void)viewDidLoad
{
    [super viewDidLoad];
    enemyList = [[NSMutableArray alloc] init];
    [enemyList addObject:@"Space Aliens"];
    [enemyList addObject:@"Rubber Ducks"];
    self.selectedRow = 0;
	// Do any additional setup after loading the view, typically from a nib.
}

- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)thePickerView
{
    return 1;
}

- (NSInteger)pickerView:(UIPickerView*)pickerView numberOfRowsInComponent:(NSInteger)component
{
    return enemyList.count;
}

- (NSString *)pickerView: (UIPickerView*)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
    return [enemyList objectAtIndex:row];
}

- (void)pickerView: (UIPickerView*)thePickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
    self.selectedRow = &(row);
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)optionButtonPressed:(id)sender
{
    if (soh == NO)
    {
        [enemyPicker setHidden:NO];
        soh=YES;
    }
    else if (soh == YES)
    {
        [enemyPicker setHidden:YES];
        soh=NO;
    }
}

- (IBAction)playButtonPressed:(id)sender
{
    if (self.selectedRow==0)
    {
        selectedRowInt = *(self.selectedRow);
        [self getEnemyType];
        [self performSegueWithIdentifier:@"push1" sender:self];
    }
    else if (self.selectedRow==-1073750132)
    {
        selectedRowInt = *(self.selectedRow);
        [self getEnemyType];
        [self performSegueWithIdentifier:@"push2" sender:self];
    }
}

- (int) getEnemyType
{
    [Enemy performSelector:@selector(setEnemyType) withObject: selectedRowInt];
}

@end
